package com.atguigu.edu.controller.front;

import com.atguigu.edu.entity.Course;
import com.atguigu.edu.entity.Teacher;
import com.atguigu.edu.service.CourseService;
import com.atguigu.edu.service.TeacherService;
import com.atguigu.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@CrossOrigin
@Api(description = "Front(名师/热门课程) 前台端口-8001")
@RequestMapping("/edu/front")
public class FrontController {

    @Resource
    private CourseService courseService;

    @Resource
    private TeacherService teacherService;

    @ApiOperation("front前台获取热门课程 View_count前8个")
    @GetMapping("/getCourse")
    public R getCourse() {
        List<Course> list = courseService.getCourseByLimit8();
        return R.ok().data("courseItems", list);

    }

    @ApiOperation("front前台获取名师 无规则前4个")
    @GetMapping("/getTeacher")
    public R getTeacher() {
        List<Teacher> list = teacherService.getTeacherByLimit4();
        return R.ok().data("teacherItems", list);
    }


}
